package com.dy.design_pattern_study.command_pattern.dome2;

import com.dy.design_pattern_study.command_pattern.dome2.impl.PrintBakeChickenWingLog;
import com.dy.design_pattern_study.command_pattern.dome2.impl.PrintBakeMuttonLog;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * @CreateBy zhangdingyi
 * @Date 2023-04-19
 * @Content 服务员类第二版
 */
public class Waiter {
    //存放增加指令的容器
    private List<Command> orders = new ArrayList<>();

    //设置订单
    public void setOrder(Command command) {

        //服务员可以对用户提出的请求进行回绝
        if (command.getClass().getSimpleName().equals("BakeChickenWingCommand")) {
            System.out.println("服务器：没有鸡翅了，请点别的！");
        } else {
            orders.add(command);
            System.out.println("增加订单：");
            printLog(command.getClass().getSimpleName());
        }
    }

   private void printLog(String logClassName) {
        switch (logClassName) {
            case "BakeChickenWingCommand":
                PrintBakeChickenWingLog.getPrintBakeChickenWingLog().printLog();
                break;
            case "BakeMuttonCommand":
                PrintBakeMuttonLog.getPrintBakeMuttonLog().printLog();
                break;
        }
    }
    //取消订单
    public void cancelOrder(Command command) {
        orders.remove(command);
        System.out.println("取消订单：");
        printLog(command.getClass().getSimpleName());
    }

    public void notifyMethod() {
        //通知后厨制作用户点好的烧烤
        for (Command order : orders) {
            order.excuteCommand();
        }

    }


}
